package com.hrpmar.service.impl;

import com.hrpmar.controller.dto.PowerDto;
import com.hrpmar.mapper.DepartmentMapper;
import com.hrpmar.mapper.DivisionMapper;
import com.hrpmar.mapper.WorkerMapper;
import com.hrpmar.pojo.Department;
import com.hrpmar.pojo.Division;
import com.hrpmar.pojo.Worker;
import com.hrpmar.service.PowerService;
import com.hrpmar.utils.Pager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by 李松松 on 2017/12/3.
 */
@Service
@Transactional
public class PowerServiceImpl implements PowerService {

    @Resource
    private WorkerMapper workerMapper;
    @Resource
    private DepartmentMapper departmentMapper;
    @Resource
    private DivisionMapper divisionMapper;
    @Override
    public Pager searchHaveLogin(PowerDto dto, Integer offset, Integer limit) {
        Pager pager = new Pager();
        List<Worker> list = workerMapper.searchHaveLogin(dto,offset,limit);
        pager.setRows(list);
        pager.setTotal(workerMapper.searchHaveLoginCount(dto));
        return pager;
    }

    @Override
    public List<Department> searchListDep() {
        return departmentMapper.searchListDep();
    }

    @Override
    public List<Worker> searchNotPwd(Integer deId) {
        return workerMapper.searchNotPwd(deId);
    }

    @Override
    public Worker searchDisplay(String woJubnum) {
        return workerMapper.searchDisplayInfo(woJubnum);
    }

    @Override
    public List<Worker> searchDivisionNotPwd() {
        return workerMapper.searchDivisionNotPwd();
    }

    @Override
    public Division searchByWoJubnum(String woJubnum) {
        return divisionMapper.searchDivisionBywoJubnum(woJubnum);
    }

    @Override
    public Integer updateUserPwd(String landPwd, String woJubnum) {
        return workerMapper.updateUserPwd(woJubnum,landPwd);
    }
}
